import java.awt.EventQueue;
import java.util.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;

import javax.swing.JLabel;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JButton;
import java.awt.Insets;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.Font;
import javax.swing.border.MatteBorder;
import java.awt.Color;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.border.LineBorder;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JCheckBox;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;

import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.*;
import javax.swing.JTextPane;

public class MainUI {
	private ArrayList<Subject> subj;
	private ArrayList<Task> tasks;
	private JFrame Main;
	private JTextField subTxt;
	private JPanel calendarStatusPanel, contPanel, welcomePanel, addSubject, mainPanel, subjectPanel, descPanel, taskPanel ;
    private JLabel lblText, lbltaskName;
    CardLayout cards;
    JTextArea descriptionArea;
    private JTextField taskField;
    private JPanel addTask;
	private JButton subConfButton;
	private JButton taskConfButton;
	JComboBox<String> subjectCombo;
	private JTable taskTable;
	private JTable subjTable;
	private DefaultTableModel subjTbModel;
	private DefaultTableModel taskTbModel;
	JLabel lblMonth, lblYear;
    JButton btnPrev, btnNext;
    JTable tblCalendar;
    JComboBox cmbYear;
    JFrame frmMain;
    JTextField textField1 = new JTextField();
	
	
    JTextField textField_11 = new JTextField();
 
	
	JTextField textField_21 = new JTextField();
	
	
	JTextField textField_31 = new JTextField();

   
    
    DefaultTableModel mtblCalendar; //Table model
    JScrollPane stblCalendar; //The scrollpane
    JPanel pnlCalendar;
     int realYear, realMonth, realDay, currentYear, currentMonth;
     private JTextField textField;
     private JTextField textField_1;
     private JTextField textField_2;
     private JTextField textField_3;
	
    /**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainUI window = new MainUI();
					window.Main.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	
	/**
	 * Create the application.
	 */
	public MainUI() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		tasks = new ArrayList<>();
		subj = new ArrayList<>();
		subjTbModel = new DefaultTableModel(0, 1) {
		    /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public boolean isCellEditable(int row, int column)
		    {
		      return false;//This causes all cells to be not editable
		    }
		  };
		taskTbModel = new DefaultTableModel(0, 1) {
		    /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public boolean isCellEditable(int row, int column)
		    {
		      return false;//This causes all cells to be not editable
		    }
		  };
		
		    
	        //Create controls
	        lblMonth = new JLabel ("January");
	        lblYear = new JLabel ("Change year:");
	        cmbYear = new JComboBox();
	        btnPrev = new JButton ("Previous");
	        btnNext = new JButton ("Next");
	        mtblCalendar = new DefaultTableModel(){/**
				 * 
				 */
				private static final long serialVersionUID = 1L;

			public boolean isCellEditable(int rowIndex, int mColIndex){return false;}};
	        tblCalendar = new JTable(mtblCalendar);
	        stblCalendar = new JScrollPane(tblCalendar);
	        pnlCalendar = new JPanel(null);
	        JLabel lblTaskDetails = new JLabel("TASK DETAILS ");
			
			JLabel lblTaskName = new JLabel("TASK NAME:");
			
			JLabel lblDueDate = new JLabel("DUE DATE:");
			
			JLabel lblSubject_1 = new JLabel("SUBJECT:");
			
			JLabel lblDescription_1 = new JLabel("DESCRIPTION:");
	       
	        btnPrev.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					if (currentMonth == 0){ //Back one year
		                currentMonth = 11;
		                currentYear -= 1;
		            }
		            else{ //Back one month
		                currentMonth -= 1;
		            }
		            refreshCalendar(currentMonth, currentYear);
				}
			});
	        btnNext.addActionListener(new ActionListener() {
	            public void actionPerformed (ActionEvent e){
	                if (currentMonth == 11){ //Foward one year
	                    currentMonth = 0;
	                    currentYear += 1;
	                }
	                else{ //Foward one month
	                    currentMonth += 1;
	                }
	                refreshCalendar(currentMonth, currentYear);
	            }
	        });
	        cmbYear.addActionListener(new ActionListener() {
	        	 public void actionPerformed (ActionEvent e){
	                 if (cmbYear.getSelectedItem() != null){
	                     String b = cmbYear.getSelectedItem().toString();
	                     currentYear = Integer.parseInt(b);
	                     refreshCalendar(currentMonth, currentYear);
	                 }
	             }
	        });
	        //Add controls to pane
	        calendarStatusPanel = new JPanel();
			
	        calendarStatusPanel.add(pnlCalendar);
	        pnlCalendar.add(lblMonth);
	        pnlCalendar.add(lblYear);
	        pnlCalendar.add(cmbYear);
	        pnlCalendar.add(btnPrev);
	        pnlCalendar.add(btnNext);
	        pnlCalendar.add(stblCalendar);

	        //Set bounds
	        pnlCalendar.setBounds(0, 0, 320, 335);
	        lblMonth.setBounds(225, 25, 91, 25);
	        lblYear.setBounds(10, 305, 80, 20);
	        cmbYear.setBounds(230, 305, 80, 20);
	        btnPrev.setBounds(10, 25, 96, 25);
	        btnNext.setBounds(230, 25, 80, 25);
	        stblCalendar.setBounds(10, 50, 300, 250);

	        //Make frame visible
	        //Get real month/year
	        GregorianCalendar cal = new GregorianCalendar(); //Create calendar
	        realDay = cal.get(GregorianCalendar.DAY_OF_MONTH); //Get day
	        realMonth = cal.get(GregorianCalendar.MONTH); //Get month
	        realYear = cal.get(GregorianCalendar.YEAR); //Get year
	        currentMonth = realMonth; //Match month and year
	        currentYear = realYear;

	        //Add headers
	        String[] headers = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; //All headers
	        for (int i=0; i<7; i++){
	            mtblCalendar.addColumn(headers[i]);
	        }

	        tblCalendar.getParent().setBackground(tblCalendar.getBackground()); //Set background

	        //No resize/reorder
	        tblCalendar.getTableHeader().setResizingAllowed(false);
	        tblCalendar.getTableHeader().setReorderingAllowed(false);

	        //Single cell selection
	        tblCalendar.setColumnSelectionAllowed(true);
	        tblCalendar.setRowSelectionAllowed(true);
	        tblCalendar.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	        //Set row/column count
	        tblCalendar.setRowHeight(38);
	        mtblCalendar.setColumnCount(7);
	        mtblCalendar.setRowCount(6);

	        //Populate table
	        for (int i=realYear-100; i<=realYear+100; i++){
	            cmbYear.addItem(String.valueOf(i));
	        }

	        //Refresh calendar
	        refreshCalendar (realMonth, realYear); //Refresh calendar

		  
		  
		  
		Main = new JFrame();
		Main.setTitle("Personal Task Manager");
		Main.setResizable(false);
		Main.setBounds(100, 100, 667, 637);
		Main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		contPanel = new JPanel();
		Main.getContentPane().add(contPanel, BorderLayout.CENTER);
		cards=new CardLayout(0, 0);
		contPanel.setLayout(cards);
		
		welcomePanel = new JPanel();
		contPanel.add(welcomePanel, "welcomePanel");
		
		lblText = new JLabel("WELCOME");
		lblText.setFont(new Font("Rockwell Extra Bold", Font.PLAIN, 75));
		
		JButton btnBegin = new JButton("BEGIN");
		btnBegin.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				cards.show(contPanel, "mainPanel");
			}
		});
		GroupLayout gl_welcomePanel = new GroupLayout(welcomePanel);
		gl_welcomePanel.setHorizontalGroup(
			gl_welcomePanel.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_welcomePanel.createSequentialGroup()
					.addContainerGap(111, Short.MAX_VALUE)
					.addGroup(gl_welcomePanel.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_welcomePanel.createSequentialGroup()
							.addComponent(lblText)
							.addGap(95))
						.addGroup(Alignment.TRAILING, gl_welcomePanel.createSequentialGroup()
							.addComponent(btnBegin, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
							.addGap(251))))
		);
		gl_welcomePanel.setVerticalGroup(
			gl_welcomePanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_welcomePanel.createSequentialGroup()
					.addGap(162)
					.addComponent(lblText, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)
					.addGap(118)
					.addComponent(btnBegin, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(187, Short.MAX_VALUE))
		);
		welcomePanel.setLayout(gl_welcomePanel);
		
		mainPanel = new JPanel();
		mainPanel.setBorder(new LineBorder(new Color(0, 0, 0)));
		contPanel.add(mainPanel, "mainPanel");
		
		subjectPanel = new JPanel();
		subjectPanel.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
		GridBagLayout gbl_subjectPanel = new GridBagLayout();
		gbl_subjectPanel.columnWidths = new int[]{98, 0, 4, 0};
		gbl_subjectPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
		gbl_subjectPanel.columnWeights = new double[]{1.0, 0.0, 1.0, Double.MIN_VALUE};
		gbl_subjectPanel.rowWeights = new double[]{0.0, 1.0, 0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
		subjectPanel.setLayout(gbl_subjectPanel);
		
		JLabel lblSubjects = new JLabel("SUBJECTS:");
		lblSubjects.setFont(new Font("Stencil", Font.PLAIN, 15));
		GridBagConstraints gbc_lblSubjects = new GridBagConstraints();
		gbc_lblSubjects.insets = new Insets(0, 0, 5, 5);
		gbc_lblSubjects.gridx = 0;
		gbc_lblSubjects.gridy = 0;
		subjectPanel.add(lblSubjects, gbc_lblSubjects);
		
		JButton subjAdd = new JButton("+");
		subjAdd.addActionListener(new ActionListener(){
				public void actionPerformed(ActionEvent e) {
					cards.show(contPanel, "addSubject");
				}
		});
		
		
		GridBagConstraints gbc_btnAdd = new GridBagConstraints();
		gbc_btnAdd.anchor = GridBagConstraints.EAST;
		gbc_btnAdd.insets = new Insets(0, 0, 5, 5);
		gbc_btnAdd.gridx = 1;
		gbc_btnAdd.gridy = 0;
		subjectPanel.add(subjAdd, gbc_btnAdd);
		
		subjTable = new JTable(subjTbModel);
		GridBagConstraints gbc_subjTable = new GridBagConstraints();
		gbc_subjTable.gridheight = 4;
		gbc_subjTable.gridwidth = 2;
		gbc_subjTable.insets = new Insets(0, 0, 5, 5);
		gbc_subjTable.fill = GridBagConstraints.BOTH;
		gbc_subjTable.gridx = 0;
		gbc_subjTable.gridy = 1;
		subjectPanel.add(subjTable, gbc_subjTable);
	  subjTable.addMouseListener(new MouseAdapter(){
          public void MouseClicked(MouseEvent e) {
        	  int i = subjTable.getSelectedRow();
        	  int j = subjTable.getSelectedColumn();
              String name = (String)subjTable.getModel().getValueAt(i,j);
              for(; i<subj.size(); i++){
            	  if(name.equalsIgnoreCase(subj.get(i).getName())){
            		  descPanel.setName(subj.get(i).getName());
            	  }
              }
           }

      });
		
		
		
		JButton btnEdit = new JButton("EDIT");
		GridBagConstraints gbc_btnEdit = new GridBagConstraints();
		gbc_btnEdit.insets = new Insets(0, 0, 0, 5);
		gbc_btnEdit.gridx = 0;
		gbc_btnEdit.gridy = 5;
		subjectPanel.add(btnEdit, gbc_btnEdit);
		
		JButton btnDelete = new JButton("DELETE");
		GridBagConstraints gbc_btnDelete = new GridBagConstraints();
		gbc_btnDelete.insets = new Insets(0, 0, 0, 5);
		gbc_btnDelete.gridx = 1;
		gbc_btnDelete.gridy = 5;
		subjectPanel.add(btnDelete, gbc_btnDelete);
		
		JPanel descPanel = new JPanel();
		descPanel.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
		
		
		
	
		GroupLayout gl_descPanel = new GroupLayout(descPanel);
		gl_descPanel.setHorizontalGroup(
			gl_descPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_descPanel.createSequentialGroup()
					.addGroup(gl_descPanel.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_descPanel.createSequentialGroup()
							.addGap(180)
							.addComponent(lblTaskDetails))
						.addGroup(gl_descPanel.createSequentialGroup()
							.addContainerGap()
							.addGroup(gl_descPanel.createParallelGroup(Alignment.LEADING, false)
								.addGroup(gl_descPanel.createSequentialGroup()
									.addComponent(lblTaskName)
									.addPreferredGap(ComponentPlacement.UNRELATED)
									.addComponent(textField1))
								.addGroup(gl_descPanel.createSequentialGroup()
									.addGroup(gl_descPanel.createParallelGroup(Alignment.LEADING)
										.addComponent(lblDueDate)
										.addComponent(lblSubject_1))
									.addGap(18)
									.addGroup(gl_descPanel.createParallelGroup(Alignment.LEADING, false)
										.addComponent(textField_11)
										.addComponent(textField_21, GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)))))
						.addGroup(gl_descPanel.createSequentialGroup()
							.addContainerGap()
							.addComponent(lblDescription_1, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(textField_31, GroupLayout.PREFERRED_SIZE, 293, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap(54, Short.MAX_VALUE))
		);
		gl_descPanel.setVerticalGroup(
			gl_descPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_descPanel.createSequentialGroup()
					.addContainerGap()
					.addComponent(lblTaskDetails)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(gl_descPanel.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblTaskName)
						.addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(17)
					.addGroup(gl_descPanel.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblDueDate)
						.addComponent(textField_11, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addGroup(gl_descPanel.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblSubject_1)
						.addComponent(textField_21, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(gl_descPanel.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblDescription_1)
						.addComponent(textField_31, GroupLayout.PREFERRED_SIZE, 74, GroupLayout.PREFERRED_SIZE))
					.addGap(97))
		);
		descPanel.setLayout(gl_descPanel);
		
		taskPanel = new JPanel();
		taskPanel.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
		GridBagLayout gbl_taskPanel = new GridBagLayout();
		gbl_taskPanel.columnWidths = new int[]{116, 80, 0};
		gbl_taskPanel.rowHeights = new int[]{23, 23, 136, 23, 0};
		gbl_taskPanel.columnWeights = new double[]{1.0, 0.0, Double.MIN_VALUE};
		gbl_taskPanel.rowWeights = new double[]{0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
		taskPanel.setLayout(gbl_taskPanel);
		
		JButton taskAdd = new JButton("+");
		taskAdd.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				cards.show(contPanel, "addTask");
			}
		});
		
		JLabel lblTask = new JLabel("TASK:");
		lblTask.setFont(new Font("Stencil", Font.PLAIN, 17));
		GridBagConstraints gbc_lblTask = new GridBagConstraints();
		gbc_lblTask.fill = GridBagConstraints.HORIZONTAL;
		gbc_lblTask.insets = new Insets(0, 0, 5, 5);
		gbc_lblTask.gridx = 0;
		gbc_lblTask.gridy = 0;
		taskPanel.add(lblTask, gbc_lblTask);
		GridBagConstraints gbc_taskAdd = new GridBagConstraints();
		gbc_taskAdd.anchor = GridBagConstraints.NORTH;
		gbc_taskAdd.insets = new Insets(0, 0, 5, 0);
		gbc_taskAdd.gridx = 1;
		gbc_taskAdd.gridy = 0;
		taskPanel.add(taskAdd, gbc_taskAdd);
		
		JButton taskHistory = new JButton("History");
		GridBagConstraints gbc_taskHistory = new GridBagConstraints();
		gbc_taskHistory.anchor = GridBagConstraints.NORTH;
		gbc_taskHistory.insets = new Insets(0, 0, 5, 0);
		gbc_taskHistory.gridx = 1;
		gbc_taskHistory.gridy = 1;
		taskPanel.add(taskHistory, gbc_taskHistory);
		taskTable = new JTable(taskTbModel);
		GridBagConstraints gbc_taskTable = new GridBagConstraints();
		gbc_taskTable.gridwidth = 2;
		gbc_taskTable.insets = new Insets(0, 0, 5, 5);
		gbc_taskTable.fill = GridBagConstraints.BOTH;
		gbc_taskTable.gridx = 0;
		gbc_taskTable.gridy = 2;
		taskPanel.add(taskTable, gbc_taskTable);
		
		JButton taskEdit = new JButton("EDIT");
		GridBagConstraints gbc_taskEdit = new GridBagConstraints();
		gbc_taskEdit.anchor = GridBagConstraints.NORTH;
		gbc_taskEdit.insets = new Insets(0, 0, 0, 5);
		gbc_taskEdit.gridx = 0;
		gbc_taskEdit.gridy = 3;
		taskPanel.add(taskEdit, gbc_taskEdit);
		
		JButton taskDelete = new JButton("DELETE");
		GridBagConstraints gbc_taskDelete = new GridBagConstraints();
		gbc_taskDelete.anchor = GridBagConstraints.NORTHWEST;
		gbc_taskDelete.gridx = 1;
		gbc_taskDelete.gridy = 3;
		taskPanel.add(taskDelete, gbc_taskDelete);
		
		calendarStatusPanel.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
		
		JPanel indicatorPanel = new JPanel();
		indicatorPanel.setOpaque(true);
		indicatorPanel.setBackground(Color.GREEN);
/*	if(dueDate.getDate()+7 == cal.get(GregorianCalendar.DAY_OF_MONTH)+7){
			indicatorPanel.setBackground(Color.ORANGE);
		}else if(dueDate.getDate()+7 == cal.get(GregorianCalendar.DAY_OF_MONTH)+7){
			indicatorPanel.setBackground(Color.RED);
		}else{
			indicatorPanel.setBackground(Color.GREEN);
		}*/
		
	//	Date dueDate = new Date(Date.dueDate());
		//Date daysOfYear = [];
		//for(Date d = new Date())
	
		
		
		GroupLayout gl_calendarStatusPanel = new GroupLayout(calendarStatusPanel);
		gl_calendarStatusPanel.setHorizontalGroup(
			gl_calendarStatusPanel.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_calendarStatusPanel.createSequentialGroup()
					.addContainerGap(318, Short.MAX_VALUE)
					.addComponent(indicatorPanel, GroupLayout.PREFERRED_SIZE, 101, GroupLayout.PREFERRED_SIZE)
					.addContainerGap())
		);
		gl_calendarStatusPanel.setVerticalGroup(
			gl_calendarStatusPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_calendarStatusPanel.createSequentialGroup()
					.addGap(50)
					.addComponent(indicatorPanel, GroupLayout.PREFERRED_SIZE, 249, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(57, Short.MAX_VALUE))
		);
		calendarStatusPanel.setLayout(gl_calendarStatusPanel);
		GroupLayout gl_mainPanel = new GroupLayout(mainPanel);
		gl_mainPanel.setHorizontalGroup(
			gl_mainPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_mainPanel.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_mainPanel.createParallelGroup(Alignment.TRAILING)
						.addComponent(taskPanel, GroupLayout.PREFERRED_SIZE, 205, GroupLayout.PREFERRED_SIZE)
						.addComponent(subjectPanel, GroupLayout.PREFERRED_SIZE, 205, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addGroup(gl_mainPanel.createParallelGroup(Alignment.LEADING)
						.addComponent(descPanel, GroupLayout.PREFERRED_SIZE, 453, GroupLayout.PREFERRED_SIZE)
						.addComponent(calendarStatusPanel, GroupLayout.PREFERRED_SIZE, 431, GroupLayout.PREFERRED_SIZE))
					.addContainerGap())
		);
		gl_mainPanel.setVerticalGroup(
			gl_mainPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_mainPanel.createSequentialGroup()
					.addGroup(gl_mainPanel.createParallelGroup(Alignment.TRAILING, false)
						.addGroup(gl_mainPanel.createSequentialGroup()
							.addComponent(subjectPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
							.addGap(18)
							.addComponent(taskPanel, GroupLayout.PREFERRED_SIZE, 290, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_mainPanel.createSequentialGroup()
							.addComponent(descPanel, GroupLayout.PREFERRED_SIZE, 237, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(calendarStatusPanel, GroupLayout.PREFERRED_SIZE, 358, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap())
		);
		mainPanel.setLayout(gl_mainPanel);
		
		addSubject = new JPanel();
		contPanel.add(addSubject, "addSubject");
		
		JLabel lblSubject = new JLabel("SUBJECT");
		
		JLabel lblTime = new JLabel("TIME");
		
		JLabel lblDays = new JLabel("DAYS");
		
		subTxt = new JTextField();
		subTxt.setColumns(10);
		
		JComboBox thirdTime = new JComboBox();
		thirdTime.addItem("AM");
		thirdTime.addItem("PM");
		
		JComboBox secondTime = new JComboBox();
		for(int i=0; i<=59; i++){
			if(i<10)
		secondTime.addItem("0"+i);
			else
				secondTime.addItem(i);
		}
		
		JComboBox firstTime = new JComboBox();
		for(int i=0; i<=12; i++){
		firstTime.addItem(i);
		}
		
		subConfButton = new JButton("CONFIRM");
		subConfButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				int[]x = {};	
				subj.add(new Subject(subTxt.getText(), x, "nadf"));
				GridBagConstraints cons= new GridBagConstraints();
				cons.insets = new Insets(0, 0, 0, 0);
				cons.gridx = 0;
				cons.gridy = subj.size();
				
				subjTbModel.addRow(new Object[]{subTxt.getText()});
				subjectCombo.addItem(subTxt.getText()+ "");
				subTxt.setText("");
				cards.show(contPanel, "mainPanel");
			}
			
		});
				
		JButton cancelAdd = new JButton("CANCEL");
		cancelAdd.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				cards.show(contPanel, "mainPanel");
				subTxt.setText("");
			}
		});
		
		JCheckBox checkTuesday = new JCheckBox("TUESDAY");
		
		JCheckBox checkWed = new JCheckBox("WEDNESDAY");
		
		JCheckBox checkThurs = new JCheckBox("THURSDAY");
		
		JCheckBox checkFriday = new JCheckBox("FRIDAY");
		
		JCheckBox checkSat = new JCheckBox("SATURDAY");
		
		JCheckBox checkMonday = new JCheckBox("MONDAY");
		
		JComboBox fourthTime = new JComboBox();
		for(int i=0; i<=12; i++){
			fourthTime.addItem(i);
			}
		
		JComboBox fifthTime = new JComboBox();
		for(int i=0; i<=59; i++){
			if(i<10)
				fifthTime.addItem("0"+i);
					else
			fifthTime.addItem(i);
			}
		
		JComboBox sixthTime = new JComboBox();
		sixthTime.addItem("AM");
		sixthTime.addItem("PM");
		
		JLabel lblTo = new JLabel("TO");
		
		JCheckBox checkBox = new JCheckBox("SUNDAY");
		GroupLayout gl_addSubject = new GroupLayout(addSubject);
		gl_addSubject.setHorizontalGroup(
			gl_addSubject.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_addSubject.createSequentialGroup()
					.addGroup(gl_addSubject.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_addSubject.createSequentialGroup()
							.addGap(34)
							.addGroup(gl_addSubject.createParallelGroup(Alignment.LEADING)
								.addComponent(lblTime)
								.addComponent(lblSubject)
								.addComponent(lblDays))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_addSubject.createParallelGroup(Alignment.LEADING)
								.addComponent(subTxt, GroupLayout.PREFERRED_SIZE, 393, GroupLayout.PREFERRED_SIZE)
								.addGroup(gl_addSubject.createSequentialGroup()
									.addGroup(gl_addSubject.createParallelGroup(Alignment.LEADING)
										.addGroup(gl_addSubject.createSequentialGroup()
											.addComponent(firstTime, GroupLayout.PREFERRED_SIZE, 54, GroupLayout.PREFERRED_SIZE)
											.addPreferredGap(ComponentPlacement.RELATED)
											.addComponent(secondTime, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE))
										.addComponent(checkTuesday)
										.addComponent(checkWed, GroupLayout.PREFERRED_SIZE, 133, GroupLayout.PREFERRED_SIZE)
										.addComponent(checkMonday))
									.addPreferredGap(ComponentPlacement.UNRELATED)
									.addGroup(gl_addSubject.createParallelGroup(Alignment.LEADING)
										.addComponent(checkSat)
										.addComponent(checkFriday)
										.addComponent(checkThurs)
										.addGroup(gl_addSubject.createParallelGroup(Alignment.TRAILING)
											.addComponent(checkBox, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE)
											.addGroup(gl_addSubject.createSequentialGroup()
												.addComponent(thirdTime, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE)
												.addPreferredGap(ComponentPlacement.UNRELATED)
												.addComponent(lblTo)
												.addPreferredGap(ComponentPlacement.UNRELATED)
												.addComponent(fourthTime, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
												.addPreferredGap(ComponentPlacement.RELATED)
												.addComponent(fifthTime, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
												.addPreferredGap(ComponentPlacement.RELATED)
												.addComponent(sixthTime, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE)))))))
						.addGroup(gl_addSubject.createSequentialGroup()
							.addGap(195)
							.addComponent(subConfButton)
							.addGap(57)
							.addComponent(cancelAdd)))
					.addGap(345))
		);
		gl_addSubject.setVerticalGroup(
			gl_addSubject.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_addSubject.createSequentialGroup()
					.addGap(48)
					.addGroup(gl_addSubject.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblSubject)
						.addComponent(subTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(44)
					.addGroup(gl_addSubject.createParallelGroup(Alignment.BASELINE)
						.addComponent(firstTime, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(secondTime, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(thirdTime, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(lblTo)
						.addComponent(lblTime)
						.addComponent(fourthTime, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(fifthTime, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(sixthTime, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(48)
					.addGroup(gl_addSubject.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblDays)
						.addComponent(checkMonday)
						.addComponent(checkThurs)
						.addComponent(checkBox))
					.addGap(18)
					.addGroup(gl_addSubject.createParallelGroup(Alignment.BASELINE)
						.addComponent(checkTuesday)
						.addComponent(checkFriday))
					.addGap(18)
					.addGroup(gl_addSubject.createParallelGroup(Alignment.BASELINE)
						.addComponent(checkWed)
						.addComponent(checkSat))
					.addGap(78)
					.addGroup(gl_addSubject.createParallelGroup(Alignment.BASELINE)
						.addComponent(subConfButton)
						.addComponent(cancelAdd))
					.addContainerGap(223, Short.MAX_VALUE))
		);
		addSubject.setLayout(gl_addSubject);
		
		addTask = new JPanel();
		addTask.setBackground(new Color(255, 255, 0));
		addTask.setForeground(Color.BLACK);
		contPanel.add(addTask, "addTask");
		
		lbltaskName = new JLabel("Task Name:");
		
		JLabel lblsubjectTask = new JLabel("Subject:");
		
		JLabel lbldueDate = new JLabel("Due Date:");
		
		JLabel lblDescription = new JLabel("Description:");
		
		taskField = new JTextField();
		taskField.setColumns(10);
		
		descriptionArea = new JTextArea();
		descriptionArea.setForeground(Color.BLACK);
		
		taskConfButton = new JButton("Confirm");
		taskConfButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				tasks.add(new Task(taskField.getText(), new Date(), subjectCombo.getToolTipText(), descriptionArea.getText()));
				GridBagConstraints cons= new GridBagConstraints();
				cons.insets = new Insets(0, 0, 0, 0);
				cons.gridx = 0;
				cons.gridy = tasks.size();
				taskTbModel.addRow(new Object[]{taskField.getText()});
				taskField.setText("");
				cards.show(contPanel, "mainPanel");				
			}
		});
		
		JButton btnCancel = new JButton("Cancel");
		btnCancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				descriptionArea.setText(null);
				cards.show(contPanel, "mainPanel");
			}
		});
		
		subjectCombo = new JComboBox<String>();
		
		String[] dueFirst = new String[]{"January","February","March","May","June","July","August","September","October","November","December"};
		JComboBox firstDue = new JComboBox();
		for(int i=0; i<dueFirst.length; i++){
			firstDue.addItem(dueFirst[i]);
		}
		
		JComboBox secondDue = new JComboBox();
		for(int i=1; i<=31; i++){
			if(i<10)
		secondDue.addItem("0"+i);
			else
				secondDue.addItem(i);
		}
		
		JComboBox thirdDue = new JComboBox();
		for(int i=2014; i<2114; i++){
			thirdDue.addItem(i);
			}
		
		
		
		GroupLayout gl_addTask = new GroupLayout(addTask);
		gl_addTask.setHorizontalGroup(
			gl_addTask.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_addTask.createSequentialGroup()
					.addGap(72)
					.addGroup(gl_addTask.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_addTask.createSequentialGroup()
							.addComponent(lbldueDate)
							.addContainerGap())
						.addGroup(gl_addTask.createSequentialGroup()
							.addGroup(gl_addTask.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_addTask.createSequentialGroup()
									.addGap(105)
									.addComponent(taskConfButton)
									.addPreferredGap(ComponentPlacement.RELATED, 143, Short.MAX_VALUE)
									.addComponent(btnCancel)
									.addGap(74))
								.addGroup(gl_addTask.createSequentialGroup()
									.addGroup(gl_addTask.createParallelGroup(Alignment.TRAILING)
										.addGroup(gl_addTask.createParallelGroup(Alignment.LEADING)
											.addComponent(lbltaskName)
											.addComponent(lblsubjectTask))
										.addComponent(lblDescription))
									.addGap(18)
									.addGroup(gl_addTask.createParallelGroup(Alignment.LEADING)
										.addComponent(subjectCombo, 0, 381, Short.MAX_VALUE)
										.addComponent(taskField, GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
										.addGroup(gl_addTask.createSequentialGroup()
											.addComponent(firstDue, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)
											.addGap(18)
											.addComponent(secondDue, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
											.addGap(30)
											.addComponent(thirdDue, GroupLayout.PREFERRED_SIZE, 78, GroupLayout.PREFERRED_SIZE))
										.addComponent(descriptionArea, GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE))))
							.addGap(133))))
		);
		gl_addTask.setVerticalGroup(
			gl_addTask.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_addTask.createSequentialGroup()
					.addGap(45)
					.addGroup(gl_addTask.createParallelGroup(Alignment.BASELINE)
						.addComponent(lbltaskName)
						.addComponent(taskField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(gl_addTask.createParallelGroup(Alignment.BASELINE)
						.addComponent(subjectCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(lblsubjectTask))
					.addGap(18)
					.addGroup(gl_addTask.createParallelGroup(Alignment.LEADING)
						.addComponent(lbldueDate)
						.addGroup(gl_addTask.createParallelGroup(Alignment.BASELINE)
							.addComponent(firstDue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addComponent(secondDue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addComponent(thirdDue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
					.addGap(73)
					.addGroup(gl_addTask.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_addTask.createSequentialGroup()
							.addComponent(descriptionArea, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE)
							.addGap(36)
							.addGroup(gl_addTask.createParallelGroup(Alignment.BASELINE)
								.addComponent(btnCancel)
								.addComponent(taskConfButton)))
						.addComponent(lblDescription))
					.addContainerGap(246, Short.MAX_VALUE))
		);
		addTask.setLayout(gl_addTask);
		
		JPanel editSubject = new JPanel();
		contPanel.add(editSubject, "name_19512484689793");
		
		JLabel lblSub = new JLabel("SUBJECT");
		
		JLabel lbltimeSub = new JLabel("TIME");
		
		JComboBox timeFirst = new JComboBox();
		
		JComboBox timeSecond = new JComboBox();
		
		JComboBox timeThird = new JComboBox();
		
		JLabel lbltoSub = new JLabel("TO");
		
		JComboBox timeFourth = new JComboBox();
		
		JComboBox timeFifth = new JComboBox();
		
		JComboBox timeSixth = new JComboBox();
		
		JLabel lblsubjectDays = new JLabel("DAYS");
		
		JCheckBox checkMon = new JCheckBox("MONDAY");
		
		JCheckBox checkTues = new JCheckBox("TUESDAY");
		
		JCheckBox checkWednesday = new JCheckBox("WEDNESDAY");
		
		JButton confirmSub = new JButton("CONFIRM");
		
		JButton cancelSub = new JButton("CANCEL");
		
		JCheckBox checkSaturday = new JCheckBox("SATURDAY");
		
		JCheckBox checkFri = new JCheckBox("FRIDAY");
		
		JCheckBox checkThursday = new JCheckBox("THURSDAY");
		
		JComboBox comboSubject = new JComboBox();
		GroupLayout gl_editSubject = new GroupLayout(editSubject);
		gl_editSubject.setHorizontalGroup(
			gl_editSubject.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_editSubject.createSequentialGroup()
					.addGap(70)
					.addGroup(gl_editSubject.createParallelGroup(Alignment.LEADING, false)
						.addGroup(gl_editSubject.createSequentialGroup()
							.addComponent(lblsubjectDays, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
							.addGap(64)
							.addComponent(checkMon, GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE)
							.addGap(107)
							.addComponent(checkThursday, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_editSubject.createSequentialGroup()
							.addGap(90)
							.addComponent(checkTues, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE)
							.addGap(123)
							.addComponent(checkFri, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_editSubject.createSequentialGroup()
							.addGap(90)
							.addComponent(checkWednesday, GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE)
							.addGap(107)
							.addComponent(checkSaturday, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_editSubject.createSequentialGroup()
							.addGap(98)
							.addComponent(confirmSub, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE)
							.addGap(64)
							.addComponent(cancelSub, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_editSubject.createSequentialGroup()
							.addComponent(lbltimeSub, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
							.addGap(45)
							.addComponent(timeFirst, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addGap(14)
							.addComponent(timeSecond, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addGap(10)
							.addComponent(timeThird, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addGap(31)
							.addComponent(lbltoSub, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
							.addGap(62)
							.addComponent(timeFourth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addGap(18)
							.addComponent(timeFifth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addGap(18)
							.addComponent(timeSixth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_editSubject.createSequentialGroup()
							.addComponent(lblSub, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE)
							.addGap(18)
							.addComponent(comboSubject, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
					.addContainerGap(127, Short.MAX_VALUE))
		);
		gl_editSubject.setVerticalGroup(
			gl_editSubject.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_editSubject.createSequentialGroup()
					.addGap(67)
					.addGroup(gl_editSubject.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblSub)
						.addComponent(comboSubject, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(37)
					.addGroup(gl_editSubject.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_editSubject.createSequentialGroup()
							.addGap(3)
							.addComponent(lbltimeSub))
						.addComponent(timeFirst, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(timeSecond, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(timeThird, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addGroup(gl_editSubject.createSequentialGroup()
							.addGap(3)
							.addComponent(lbltoSub))
						.addComponent(timeFourth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(timeFifth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(timeSixth, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addGroup(gl_editSubject.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_editSubject.createSequentialGroup()
							.addGap(4)
							.addComponent(lblsubjectDays))
						.addComponent(checkMon)
						.addComponent(checkThursday))
					.addGap(3)
					.addGroup(gl_editSubject.createParallelGroup(Alignment.LEADING)
						.addComponent(checkTues)
						.addComponent(checkFri))
					.addGap(3)
					.addGroup(gl_editSubject.createParallelGroup(Alignment.LEADING)
						.addComponent(checkWednesday)
						.addComponent(checkSaturday))
					.addGap(62)
					.addGroup(gl_editSubject.createParallelGroup(Alignment.LEADING)
						.addComponent(confirmSub)
						.addComponent(cancelSub))
					.addContainerGap(79, Short.MAX_VALUE))
		);
		editSubject.setLayout(gl_editSubject);
		
		JPanel editTask = new JPanel();
		contPanel.add(editTask, "name_19794640272835");
		
		JLabel lbltName = new JLabel("Task Name:");
		
		JLabel lblSubj = new JLabel("Subject:");
		
		JLabel lblTym = new JLabel("Time:");
		
		JLabel lblDescript = new JLabel("Description:");
		
		JTextArea textDescrip = new JTextArea();
		textDescrip.setForeground(Color.BLACK);
		
		JComboBox subCombo = new JComboBox();
		
		JButton confirmationButton = new JButton("Confirm");
		
		JButton cancelButton = new JButton("Cancel");
		
		JComboBox dropCombo2 = new JComboBox();
		
		JComboBox dropTime1 = new JComboBox();
		
		JComboBox dropTime3 = new JComboBox();
		
		JLabel lblDdate = new JLabel("Due Date:");
		
		JComboBox dropCombo1 = new JComboBox();
		
		JComboBox dropCombo3 = new JComboBox();		
		JComboBox dropTime2 = new JComboBox();		
		JComboBox taskCombo = new JComboBox();
		GroupLayout gl_editTask = new GroupLayout(editTask);
		gl_editTask.setHorizontalGroup(
			gl_editTask.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_editTask.createSequentialGroup()
					.addGroup(gl_editTask.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_editTask.createSequentialGroup()
							.addGap(95)
							.addGroup(gl_editTask.createParallelGroup(Alignment.TRAILING)
								.addGroup(gl_editTask.createSequentialGroup()
									.addGroup(gl_editTask.createParallelGroup(Alignment.LEADING)
										.addComponent(lblTym, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE)
										.addComponent(lblDescript, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE))
									.addGap(10))
								.addGroup(gl_editTask.createSequentialGroup()
									.addComponent(lblDdate, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE)
									.addGap(17))
								.addGroup(gl_editTask.createSequentialGroup()
									.addGroup(gl_editTask.createParallelGroup(Alignment.LEADING)
										.addComponent(lblSubj, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE)
										.addComponent(lbltName, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE))
									.addGap(10)))
							.addGroup(gl_editTask.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_editTask.createSequentialGroup()
									.addGap(10)
									.addGroup(gl_editTask.createParallelGroup(Alignment.LEADING)
										.addComponent(dropTime1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
										.addGroup(gl_editTask.createSequentialGroup()
											.addComponent(dropCombo1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
											.addGap(47)
											.addGroup(gl_editTask.createParallelGroup(Alignment.LEADING)
												.addComponent(dropCombo2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
												.addComponent(dropTime2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
											.addGap(45)
											.addGroup(gl_editTask.createParallelGroup(Alignment.LEADING)
												.addComponent(dropTime3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
												.addComponent(dropCombo3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
										.addComponent(textDescrip, GroupLayout.PREFERRED_SIZE, 314, GroupLayout.PREFERRED_SIZE)))
								.addGroup(gl_editTask.createSequentialGroup()
									.addPreferredGap(ComponentPlacement.UNRELATED)
									.addGroup(gl_editTask.createParallelGroup(Alignment.LEADING)
										.addComponent(subCombo, GroupLayout.PREFERRED_SIZE, 315, GroupLayout.PREFERRED_SIZE)
										.addComponent(taskCombo, GroupLayout.PREFERRED_SIZE, 315, GroupLayout.PREFERRED_SIZE)))))
						.addGroup(gl_editTask.createSequentialGroup()
							.addGap(214)
							.addComponent(confirmationButton, GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE)
							.addGap(74)
							.addComponent(cancelButton, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE)))
					.addContainerGap(22, Short.MAX_VALUE))
		);
		gl_editTask.setVerticalGroup(
			gl_editTask.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_editTask.createSequentialGroup()
					.addGap(56)
					.addGroup(gl_editTask.createParallelGroup(Alignment.TRAILING)
						.addGroup(gl_editTask.createSequentialGroup()
							.addGroup(gl_editTask.createParallelGroup(Alignment.BASELINE)
								.addComponent(taskCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lbltName))
							.addGap(12)
							.addGroup(gl_editTask.createParallelGroup(Alignment.BASELINE)
								.addComponent(subCombo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblSubj))
							.addGap(18)
							.addGroup(gl_editTask.createParallelGroup(Alignment.BASELINE)
								.addComponent(dropCombo1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(dropCombo2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(dropCombo3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
						.addComponent(lblDdate))
					.addGap(18)
					.addGroup(gl_editTask.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_editTask.createParallelGroup(Alignment.BASELINE)
							.addComponent(dropTime1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addComponent(lblTym))
						.addGroup(gl_editTask.createSequentialGroup()
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_editTask.createParallelGroup(Alignment.BASELINE)
								.addComponent(dropTime2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(dropTime3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
					.addGap(38)
					.addGroup(gl_editTask.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_editTask.createSequentialGroup()
							.addComponent(textDescrip, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE)
							.addGap(18)
							.addGroup(gl_editTask.createParallelGroup(Alignment.BASELINE)
								.addComponent(confirmationButton)
								.addComponent(cancelButton)))
						.addComponent(lblDescript))
					.addContainerGap(57, Short.MAX_VALUE))
		);
		editTask.setLayout(gl_editTask);
	}
	
	
	public void refreshCalendar(int month, int year){
        //Variables
        String[] months =  {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
        int nod, som; //Number Of Days, Start Of Month

        //Allow/disallow buttons
        btnPrev.setEnabled(true);
        btnNext.setEnabled(true);
        if (month == 0 && year <= realYear-10){btnPrev.setEnabled(false);} //Too early
        if (month == 11 && year >= realYear+100){btnNext.setEnabled(false);} //Too late
        lblMonth.setText(months[month]); //Refresh the month label (at the top)
        lblMonth.setBounds(160-lblMonth.getPreferredSize().width/2, 25, 180, 25); //Re-align label with calendar
        cmbYear.setSelectedItem(String.valueOf(year)); //Select the correct year in the combo box

        //Clear table
        for (int i=0; i<6; i++){
            for (int j=0; j<7; j++){
                mtblCalendar.setValueAt(null, i, j);
            }
        }

        //Get first day of month and number of days
        GregorianCalendar cal = new GregorianCalendar(year, month, 1);
        nod = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
        som = cal.get(GregorianCalendar.DAY_OF_WEEK);

        //Draw calendar
        for (int i=1; i<=nod; i++){
            int row = new Integer((i+som-2)/7);
            int column  =  (i+som-2)%7;
            mtblCalendar.setValueAt(i, row, column);
		}

        //Apply renderers
        tblCalendar.setDefaultRenderer(tblCalendar.getColumnClass(0), new tblCalendarRenderer());
    }
	
	class tblCalendarRenderer extends DefaultTableCellRenderer{
        /**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		public Component getTableCellRendererComponent (JTable table, Object value, boolean selected, boolean focused, int row, int column){
            super.getTableCellRendererComponent(table, value, selected, focused, row, column);
            if (column == 0 || column == 6){ //Week-end
                setBackground(new Color(255, 220, 220));
            }
            else{ //Week
                setBackground(new Color(255, 255, 255));
            }
            if (value != null){
                if (Integer.parseInt(value.toString()) == realDay && currentMonth == realMonth && currentYear == realYear){ //Today
                    setBackground(new Color(220, 220, 255));
                }
            }
            setBorder(null);
            setForeground(Color.black);
            return this;
        }
    }
}
